//
// Created by wze-zero on 2024/9/17 017.
//
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int left = -1, right = n - 1, up = 0, down = n - 1, value = 1;
    int num[n][n];
    while (value <= n * n) {
        for (int i = ++left; i <= right; ++i, ++value) {
            num[up][i] = value;
        }
        for (int i = ++up; i <= down; ++i, ++value) {
            num[i][right] = value;
        }
        for (int i = --right; i >= left; --i, ++value) {
            num[down][i] = value;
        }
        for (int i = --down; i >= up; --i, ++value) {
            num[i][left] = value;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << num[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}
